/************************************************************************************************/
/*Lab 3: AssemblerClasses.h									*/
/*												*/
/*Description: This header file declares the "AssemblerData", the "AssemblyCommands", and	*/
/*	       the "Comments" classes and commands for those classes that will be used for an 	*/
/*	       assembler.									*/
/*												*/
/*Modification Log:										*/
/*												*/
/*		2012/02/14 - Made this file a little more consistant in the way it is formatted.*/
/*			     Modified the return string functions to return strings instead of	*/
/*			     pointers.  Declared Length, Append commands, and one special	*/
/*			     command (tests if vector "error" is empty) for the "AssemblerData" */
/*			     class. --Note, may want to seperate directives and labels into	*/
/*			     their own separate vectors and classes.-- (Samuel Thacker)		*/
/*		2012/02/13 - Added "Errors" class and modified all vector and string variables	*/
/*			     to be pointers. (Samuel Thacker)					*/
/*		2012/02/10 - Did some slight modifications to the code to fix some potential	*/
/*			     bugs, renamed the file from "AssemblerData.h" to			*/
/*			     "AssemblerClasses.h", added comments to the end of each class	*/
/*			     declaration to help organize the file, and made some modifications	*/
/*			     to this comments section. (Samuel Thacker)				*/
/*		2012/02/09 - Creations of this header file with declarations of the 		*/
/*			     AssemberData, the AssemblyCommands, and the Comments classes,	*/
/*			     construtors and destructors for those classes, and some return	*/
/*			     commands for those structures. (Samuel Thacker)			*/
/*												*/
/*               ----Please report any modifications made to this file please----               */
/************************************************************************************************/

#ifndef ASSEMBLERCLASSES_H
#define ASSEMBLERCLASSES_H

#include <vector>
#include <string>

using namespace std;

class AssemblerData;
class AssemblyCommands;
class Comments;
class Errors;

class AssemblerData //Stores a list of assembly commands, a list of comments, and a list of data.
	{
	vector<AssemblyCommands> * data; //Where the assembly commands will be stored.
	vector<Comments> * comments; //Where the comments will be stored.
	vector<unsigned int> * mc_data; //Where the machine code data will be stored.
	vector<Errors> * errors; //Where the errors that are encountered will be stored.

	unsigned int ln; //The number of lines in the assembly file (or the current line position when going through the assembly file).

	public:
		/* Constructor and Destructor */
		AssemblerData();
		~AssemblerData();

		/* Return Commands */
		unsigned int ret_ln(); //Returns "ln"
		vector<AssemblyCommands> * ret_data(); //Returns "data" (pointer)
		vector<Comments> * ret_com(); //Returns "comments" (pointer)
		vector<unsigned int> * ret_mcData(); //Returns "mc_data" (pointer)
		vector<Errors> * ret_err(); //Returns "errors" (pointer)

		/* Length Commands */
		unsigned int data_len(); //Returns the number of elements in "data"
		unsigned int com_len(); //Returns the number of elements in "comments"
		unsigned int mcData_len(); //Returns the number of elements in "mc_data"
		unsigned int err_len(); //Returns the number of elements in "errors"

		/* Append Commands */
		//"AssemblyCommands" Append Commands//
		void data_append(string,string,string,string); //Appends an R-type instruction (string) to "Data"
		void data_append(string,string,string); //Appends an I-type instruction (string) to "Data"
		void data_append(string,string); //Appends a J-type instruction (string) to "Data"
		void data_append(string, char); //Appends a Directive or Label (string) to "Data"

		//Other Append Commands//
		void com_append(string); //Appends a comment to "comments"
		void mcData_append(unsigned int); //Appends machine code (integer) to "mc_data"
		void err_append(string); //Appends an error (string) tor "errors"

		/* Special Commands */
		bool err_empty(); //Checks if vector "error" is empty. 1 if it is and 0 if otherwise.
	}; //END class AssemblerData

class AssemblyCommands //Stores assembly commands and the line number it was on.
	{
	/* Places where the assembly commands are stored. */
	string * odl; //operation code, directive, or label
	string * reg_1; //register 1
	string * reg_2; //register 2
	string * reg_3; //register 3
	char indicator; //Indicates whether this class contains operation code (0,1,2), a directive (3), or a label (4).
	unsigned int ln; //line number

	public:
		/* Constructors */
		AssemberCommands(string,string,string,string, unsigned int); //R-type Instruction
		AssemberCommands(string,string,string, unsigned int); //I-type Instruction
		AssemberCommands(string,string, unsigned int); //J-type Instruction
		AssemberCommands(string, unsigned int, char); //Directive or Label

		/* Destructor */
		~AssemberCommands();

		/* Return Commands */
		string ret_odl(); //returns what "odl" points to
		string ret_r1(); //returns what "reg_1" points to
		string ret_r2(); //returns what reg_2" points to
		string ret_r3(); //returns what "reg_3" points to
		char ret_ind(); //returns "indicator"
		unsigned int ret_ln(); //returns "ln"
	}; //END class AssemblyCommands

class Comments //Stores a comment and the line number it was on.
	{
	string * com; //comment
	unsigned int ln; //Line number the comment is on.

	public:
		/* Constructor and Destructor */
		AssemberCommands(string,unsigned int);
		~AssemberCommands();

		/* Return Commands */
		string ret_com(); //returns what "com" points to
		unsigned int ret_ln(); //returns "ln"
	}; //END class Comments

class Errors //Stores a list of errors that may occur during the assembling of the program.
	{
	string * err; //error
	unsigned int ln; // Line number the error is on.

	public:
		/*Constructor and Destructor */
		Errors(string,unsigned int);
		~Errors();

		/* Return Commands */
		string ret_err(); //returns what "err" points to
		unsigned ret_ln(); //returns "ln"
	} //END class Errors

#endif //ASSEMBLERCLASSES_H

